package com.tywj.buscustomerapp.view.activity;

import android.app.Activity;
import android.content.IntentFilter;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.transition.Transition;
import android.transition.TransitionInflater;
import android.view.Window;
import android.view.WindowManager;

import com.tywj.buscustomerapp.R;
import com.tywj.buscustomerapp.broadcast.NetWorkStateReceiver;

import butterknife.ButterKnife;
import butterknife.Unbinder;

public abstract class BaseActivity extends AppCompatActivity {

    private Unbinder unbinder;
    @LayoutRes
    protected abstract int getContentId();
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
        initTheme();
        setContentView(getContentId());
        unbinder = ButterKnife.bind(this);
        initWidget(savedInstanceState);
        initData();
        initClick();
    }

    public static void cancelFullScreen(Activity activity) {
        activity.getWindow().clearFlags(
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

    public static void setWindowStatusBarColor(Activity activity, int colorResId) {
        try {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                Window window = activity.getWindow();
                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                window.setStatusBarColor(activity.getResources().getColor(colorResId));

                //底部导航栏
                //window.setNavigationBarColor(activity.getResources().getColor(colorResId));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    protected void initTheme(){

    }


    protected void initData(){

    }

    protected void initWidget(Bundle savedInstanceState){

    }

    protected void initClick(){}

    @Override
    protected void onDestroy() {
        super.onDestroy();
        unbinder.unbind();
    }
    //        button = findViewById(R.id.submitTest);
//        button.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                new Thread(new Runnable() {
//                    @Override
//                    public void run() {
//                        try {
//                            String WSDL_URI = "http://192.168.2.119:8888/wsdl/ITYWJAPP";//wsdl 的uri
//                            String namespace = "http://tempuri.org/";//namespace
//                            String methodName = "helloword";//要调用的方法名称
//                            SoapObject request = new SoapObject(namespace, methodName);
//                            // 设置需调用WebService接口需要传入的两个参数mobileCode、userId
//                            request.addProperty("s", "");
//                            //创建SoapSerializationEnvelope 对象，同时指定soap版本号(之前在wsdl中看到的)
//                            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapSerializationEnvelope.VER11);
//                            envelope.bodyOut = request;//由于是发送请求，所以是设置bodyOut
//                            envelope.dotNet = true;//由于是.net开发的webservice，所以这里要设置为true
//                            HttpTransportSE httpTransportSE = new HttpTransportSE(WSDL_URI);
//                            httpTransportSE.call(null, envelope);//调用
//                            // 获取返回的数据
//                            SoapObject object = (SoapObject) envelope.bodyIn;
//                            // 获取返回的结果
//                            String result = object.getProperty(0).toString();
//                            LogUtils.i("获取到的数据------>",result);
//                        } catch (Exception e) {
//                            e.printStackTrace();
//                        }
//                    }
//                }).start();
//            }
//        });

//    webservicesUntils webserviceUntils = new webservicesUntils();
//    String msg = webserviceUntils.getIndexItemList();
//                            LogUtils.i(msg);
}
